<template>
  <template v-for="menu in userMenu">
    <el-sub-menu
      v-if="
        menu.children &&
        menu.children.length > 0 &&
        menu.children[0].menuType == 1
      "
      :index="menu.path"
    >
      <template #title>
        <el-icon>
           <component :is="menu.menuIcon ? menu.menuIcon : 'setting'" />
        </el-icon>
        
        <!-- <Setting class="nav-setting"></Setting> -->
        <span>{{ menu.menuName }}</span>
      </template>
      <tree-menu :userMenu="menu.children"></tree-menu>
    </el-sub-menu>
    <el-menu-item v-else-if="menu.menuType == 1" :index="menu.path">
      <span> {{
      menu.menuName
    }}</span>
     </el-menu-item>
  </template>
</template>
<script>
import { Setting, Management, Goods, User  } from '@element-plus/icons-vue' // 需要导入图标组件
export default {
  name: "TreeMenu",
   components: {
    Setting,
    Management,
    Goods,
    User
  },
  props: {
    userMenu: {
      type: Array,
      default() {
        return [];
      },
    },
  },
};

</script>
